package handler

import (
	v1 "gin-vben-admin/api/v1"
	"gin-vben-admin/pkg/captcha"
	"github.com/gin-gonic/gin"
)

type CommonHandler struct {
	*Handler
	capt *captcha.Captcha
}

func NewCommonHandler(handler *Handler, capt *captcha.Captcha) *CommonHandler {
	return &CommonHandler{
		Handler: handler,
		capt:    capt,
	}
}

// GetProfile godoc
// @Summary 获取用户信息
// @Schemes
// @Description
// @Tags 用户模块
// @Accept json
// @Produce json
// @Security Bearer
// @Success 200 {object} v1.GetProfileResponse
// @Router /user [get]
func (h *CommonHandler) GetCaptcha(ctx *gin.Context) {
	data := v1.CaptchaRes{}
	var err error
	data.CaptchaId, data.CaptchaImg, err = h.capt.Image()
	v1.Response(ctx, err, data)
}
